package com.foogui.bootrabbitmq.delay;

import com.foogui.bootrabbitmq.dto.Msg;
import com.foogui.common.model.Result;
import com.foogui.common.utils.JsonUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.Date;
import java.util.UUID;



@RestController
@RequestMapping("/delay")
public class DelayController {


    @Autowired
    private DelayProducerService delayProducerService;

    @GetMapping("/test5S")
    public Result<Object> test5S() {
        String msg = buildMsgJsonStr();
        delayProducerService.sendDelay5SMessage(msg);
        return Result.success();
    }


    private String buildMsgJsonStr() {
        Msg msg = Msg.builder()
                .id(UUID.randomUUID().toString())
                .body("消息测试数据")
                .timestamp(new Date())
                .build();
        return JsonUtils.toJson(msg);
    }
    private Msg buildMsg() {
        return  Msg.builder()
                .id(UUID.randomUUID().toString())
                .body("消息测试数据")
                .timestamp(new Date())
                .build();
    }
}
